home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / freetype.zip / freetype.txt < prev    next >
Text File  |  1996-09-07  |  18KB  |  458 lines

  1.  
  2.  
  3.                            Welcome to the
  4.           
  5.                   F R E E T Y P E    P R O J E C T
  6.       
  7.  
  8.                    The FREE TrueType Font Engine
  9.  
  10.                      Copyright 1996 David Turner
  11.  
  12.  
  13.  
  14. This document is an introduction to the  FreeType  project,  a  very
  15. efficient  and fast, though portable, TrueType font rendering engine
  16. *freely available*.  The reader's good  knowledge  of  the  TrueType
  17. Font  specification  is  not  required,  though  being  a indeniable
  18. "plus".
  19.  
  20. ---------------------------------------------------------------------
  21.  
  22. TABLE OF CONTENTS :
  23.  
  24.    Introduction :
  25.  
  26. I. Engine Design Goals :
  27.  
  28.   1. Easy Maintenance
  29.   2. System Independance
  30.   3. Reliability
  31.   4. High Quality
  32.   5. Speed !
  33.  
  34. II. Engine Architecture :
  35.  
  36.   1. Component Hierarchy
  37.   2. Runtime Execution
  38.  
  39. II. Internals :
  40.  
  41.   1. Engine Memory Management.
  42.   2. Rasterizer mechanics.
  43.   3. Interpreting TrueType opcodes.
  44.  
  45. III. Engine Characteristics :
  46.  
  47.   1. Differences found between TrueType specs and real-world
  48.      font files.
  49.  
  50.   2. Engine's behaviour with incorrect font files or glyphs.
  51.  
  52. IV. What to do now ? :
  53.  
  54.   1. Debug the whole interpreter..
  55.  
  56.   2. Add more character-oriented functions.
  57.  
  58.   3. Porting considerations ( IMPORTANT ).
  59.  
  60. --------------------------------------------------------------------
  61.  
  62. Introduction :
  63. --------------
  64.  
  65. Managing fonts can be a serious task !
  66.  
  67.     In these good old days when all we had were dot-matrix printers,
  68. it was common practice to  use  bitmap files to print and/or display
  69. text.  This could lead to the use of a lot of disk  space,  as  each
  70. pointsize of a same typeface had to be bitmapped in a separate file.
  71. Moreover,  it  made  creating  new  typefaces  incredibly  slow  and
  72. painful, as the file for each size had to be generated.
  73.  
  74.     The  first  system  which  included automaticaly-computed bitmap
  75. files from a description  was  undoubtly  Metafonts, part of the TeX
  76. package from Donald Knuth, which is still widely  used  in  academia
  77. and  research nowadays !  Metafonts is a font specification language
  78. and bitmap generator.  It produces  the bitmaps that the TeX program
  79. uses to generate its 'DVI' ( DeVice-Independent ) files.
  80.     Unlike modern systems, it's a stand-alone product  that  is  not
  81. integrated into TeX, and does not  work "on-demand".  It must be run
  82. by the user before any TeX processing to generate the bitmap  files.
  83.  
  84.     Metafonts  was a masterpiece at the time it was invented, and in
  85. many ways, it still  is,  with  features  that  have  yet to come to
  86. modern systems ( like family-generation :  give him the  description
  87. of  an  A,  and  it will generate all others letters of the alphabet
  88. with the same style !!  ).
  89.  
  90.     Metafonts  did  not  resolve  the  disk  space  problem, it just
  91. automated the bitmap generation and made it fairly easy.  Meanwhile,
  92. the advent of laser  printers  and  graphical environments urged the
  93. need  for  a  suitable  'on-demand'  font  rendering  system.    Not
  94. surprisingly,   Adobe  which  led  the  laser  revolution  with  its
  95. Postcript printing language, proposed the  Type 1 Font Format.  This
  96. format is based on a vector specification of each glyph as  well  as
  97. the  presence  of  small  instructions,  called  'hinting',  to help
  98. preserve some aesthetics properties  of  the fonts when rendering to
  99. small sizes ( like keeping the width of the two vertical bars of a H
  100. the same, for example ).  As Type  1  was  one  of  Postcript's  key
  101. points,  laser printers became the choice of quality of many, as the
  102. quality of the printed texts out-performed by far dot-matrix.
  103.  
  104.     A  Type 1 font was typically downloaded into the laser printer's
  105. memory, where all rendering  calculations  took  place; there was no
  106. need for extra work from the computer.  This is why early  windowing
  107. systems  started  to  allow  printing with Type 1 fonts on Postcript
  108. printers,  while  keeping  their  weak  bitmap  files  for  display.
  109. Moreover, Adobe refused to license the font rendering code to  Apple
  110. and  Microsoft.   The two software giants decided then to team up to
  111. create a new font technology,  today known as 'TrueType'.  Few weeks
  112. after they had agreed, Adobe announced ATM ( Adobe Type Manager ), a
  113. product  that  allowed  (  and still does !  ) Macintosh and Windows
  114. owner to display Type 1  fonts  and  (at last) do some real WYSIWYG.
  115. What is funny is that neither products were even written on paper at
  116. that time.
  117.  
  118.    Adobe benefited from the vast momentum of already available  Type
  119. 1  fonts,  most  Typeface  designers  having been converted to their
  120. format.  It is still widely  used  in corporations where the quality
  121. of the fonts used is important (  Publishing,  Advertising,  ..   ),
  122. while  TrueType,  which finally came out and became part of System 7
  123. and Windows 3.0, is a source of  free or cheap low-level fonts for a
  124. lot of every-day jobs.  Though, more and more new fonts are proposed
  125. in both formats today.
  126.  
  127.    So the question is :   why  make  a TrueType engine rather than a
  128. Type 1 one ?
  129.  
  130.    Well, few years ago, if  someone  wanted some good quality fonts,
  131. one had  to  purchase  them  in  Type  1  format  from  professional
  132. designers.   This  seems not to be so true today, after we bought so
  133. many of  these  troublesome  but  cheap  Windows  PCs. Moreover, the
  134. TrueType specification includes a much  better  hinting  facility  :
  135. you can actually *read* TrueType fonts at 12 pts on  a  VGA  screen,
  136. while  this  is  unlikely with ATM whose rendering of small sizes is
  137. jerky, to say the least (  just  ask  any OS/2 user out there !!  ).
  138.  
  139.    Finally, there *is* already a freely available Type  1  renderer,
  140. donated  by  IBM to the X Consortium.  Look for source distributions
  141. of X11r6 for it !  It works, the source isn't really readable ( IMHO
  142. ) and suffers from a  "weird"  implementation  ( still IMHO ), to be
  143. polite !
  144.  
  145.    The FreeType project aims the development of  a  TrueType  engine
  146. that can be  easily  ported  across  platforms,  while  being  fast,
  147. accurate and stable. Simply.
  148.  
  149.  
  150.  
  151.  
  152. I. Engine Design Goals :
  153. ------------------------
  154.  
  155. This  section  describes  the  several  goals  the  engine  has been
  156. developped for :
  157.  
  158.  
  159.   - Easy maintenance :
  160.  
  161.       In an age where all 'serious' programming is done in C or C++,
  162.       the author decided to code the engine in PASCAL  !   This  may
  163.       seem  rather  weird,  but  this  language comes on the PC with
  164.       high-quality programming environments  (  namely Borland's for
  165.       DOS, and Virtual Pascal  on  OS/2  )  that  allow  light-speed
  166.       compilation,  real  module  separation and easy debugging.
  167.       
  168.       The  drawback  of  these  compilers  ( i.e. a poorly, if ever,
  169.       optimised generated  code  )  forced  development  to focus on
  170.       algorithm  fine-tuning,  rather  than clever macro tricks, and
  171.       the  tendency  to  optimize  'on   the  run'  so  usual  of  C
  172.       programmers ( a practice that easily leads to weird and hardly
  173.       maintainable code ).
  174.  
  175.       This approach, though quite constraining at first,  paid  back
  176.       faster than expected.  The project is now a well crafted piece
  177.       of software, and runs *fast*  even under Borland Pascal.  This
  178.       is unoptimized code, and one could expect a great  performance
  179.       increase  by  translating  to  C  and  using a good optimizing
  180.       compiler like GCC, or even to assembly.
  181.  
  182.       The  current version has been compiled and tested on Borland's
  183.       16 bits Pascal  Compilers  ( Turbo-Pascal, Borland-Pascal Real
  184.       Mode, and Borland-Pascal DPMI ) as well as  the  32  bit  OS/2
  185.       Virtual  Pascal  compiler  (  a  *must-have*  ).   The 32-bits
  186.       version is  about  2.5  to  3  times  faster  than  its 16-bit
  187.       counterpart.  This is mainly due to the fact that most of  the
  188.       data processed by the  engine  is  32-bit,  a painful task for
  189.       16-bit programs..
  190.  
  191.       There exist  some  small  differences  between  the 16-bit and
  192.       32-bit engines, coming from very short bui